<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>条件渲染</title>
  <script src="../vue.js"></script>
</head>
<body>
  <div id="app">
    <h1 v-if="show">我是主标题</h1>
    <!-- <h2 v-else>我是副标题</h2> -->

    <template v-if="loginType === 'username'">
      <label>Username</label>
      <input placeholder="Enter your username" key="username">
    </template>
    <template v-else>
      <label>Email</label>
      <input placeholder="Enter your email address" key="email">
    </template>

    <div>
      <button @click="changeType">change</button>
    </div>

    <p v-show="showLine">line 1</p>
    <p v-show="!showLine">content text</p>

    <ul>
      <template v-if="fruit!=='🥔'">
        <li v-for="fruit in fruits">
          <li>{{fruit}}</li>
        </li>
      </template>
    </ul>
    
  </div>
  <script>
    new Vue({
      el: '#app',
      data: {
        show: false,
        loginType: 'username',
        showLine: true,
        fruits: [
          '🍌',
          '🍒',
          '🍉',
          '🥔'
        ]
      },
      methods: {
        changeType() {
          this.loginType = 'email'
        }
      },
    })
  </script>
</body>
</html>